home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / dialogic.zip / EXAMPLE.BAS < prev    next >
BASIC Source File  |  1990-01-31  |  5KB  |  118 lines

  1. '
  2. '┌───────────────────────────────────────────────────────┐
  3. '│ Written by Jonathan S. Waldman                        │
  4. '│ (C) 1989, 1990 Jonathan S. Waldman & Dialog Software  │
  5. '│ (C) Crescent Software.                                │
  6. '│ All rights reserved.                                  │
  7. '└───────────────────────────────────────────────────────┘
  8.  
  9. 'EXAMPLE1.BAS - This will serve as a prototype for most of the dialog boxes
  10. '               you will need to generate.
  11. '
  12. 'This program demonstrates the use of a single-tasking unstacked dialog boxes.
  13. '  When you run this, you may enter a search string and select various
  14. '  options.  If you choose <Help> a new dialog box will appear with help
  15. '  text.  When you are finished reading the help, you may close the dialog
  16. '  box by pressing <Enter>.  At this point, this program will re-generate
  17. '  the Search dialog box by filling it with all the options you chose before
  18. '  <Help> was requested.  The primary dialog box (Search, in this case) will
  19. '  continue to appear until Help is NOT chosen or until <Esc> is pressed.
  20. '
  21. 'Please notice that this example defines some strings at the beginning, such
  22. '  as Cancel$ and Help$.  You should also notice that the Find template
  23. '  uses these strings in the command button definitions.  Further, other
  24. '  variables, such as Search$ and WholeWords, are used to set a re-generated
  25. '  Find dialog box to its previously-set values.
  26.  
  27.  
  28. DEFINT A-Z
  29.  
  30. '$INCLUDE: 'DIALOGIC.BI'      'include DiaLogic's TYPE definitions
  31.  
  32. CALL InitMouse(There%)
  33. IF There% THEN
  34.    CALL ShowCursor            'show the mouse
  35.    CALL TextCursor(0, 4)      'use this to insure mouse cursor is visible
  36. END IF
  37.  
  38. WIDTH , 25                    'insure we're in 25-line mode
  39. CLS                           'clear the screen
  40.  
  41.  
  42. '$DYNAMIC                     'make all arrays dynamic
  43.  
  44. MaxDBE = 20                   'use for our dimension statements
  45.                               '  20 dialog box elements will be our max
  46.  
  47. Cancel$ = CHR$(27)            'these are our string assignments, also used
  48. Help$ = CHR$(0) + CHR$(59)    '  in the FIND.DB template.
  49. OK$ = CHR$(13)
  50.  
  51. Search$ = ""                  'initialize Search$ to null
  52. ExitLoop = 0                  'stay in loop until <OK> or <Cancel> is
  53.                               '  chosen
  54. DO
  55.    REDIM SHARED DB(2, MaxDBE) AS DialogType  'REDIM these TYPE arrays
  56.    REDIM SHARED LB(0) AS DialogText          '   as dynamic
  57.  
  58.    Level% = 1                    'set Level% to 1
  59.    '$INCLUDE: 'SEARCH.DB'        'then include our dialog box template
  60.    DB(Level%, 2).TextString = Search$
  61.    Action% = 0                   'set Action% to 0
  62.    Focus% = 0                    'set the input focus to auto -- 0
  63.  
  64.    CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)    'Call DiaLogic
  65.  
  66.    'When program execution returns here the dialog box already will have been
  67.    '  cleared from the screen.  If <Help> is chosen we'll generate a Help
  68.    '  dialog box.  We'll also check to see if <Esc> was pressed or if <OK>
  69.    '  was entered, in which case we can get the search string and conduct
  70.    '  a search.
  71.  
  72.  
  73.    'Now we can store dialog box information in local variables.  These
  74.    '  variables also appear in the template definition.
  75.  
  76.    Search$ = MID$(DB(Level%, 2).TextString, 1, DB(Level%, 2).NumberOne)
  77.    MatchCase = DB(Level%, 3).Default    '-1 if Match Case check box is checked
  78.    WholeWord = DB(Level%, 4).Default    '-1 if Whole Words is checked
  79.    SearchType = DB(Level%, 5).Default   '1 for Active Window, 2 for Current
  80.                                         '   Module, 3 for All Modules
  81.    COLOR 7, 0
  82.    SELECT CASE Ky$
  83.       CASE Cancel$                      '<Cancel> pressed
  84.          PRINT "You pushed <Cancel>."
  85.          ExitLoop = -1
  86.       CASE Help$
  87.          REDIM SHARED DB(2, MaxDBE) AS DialogType  'REDIM these TYPE arrays as dynamic
  88.          REDIM SHARED LB(10) AS DialogText
  89.  
  90.          Level% = 1                     'set Level% to 1
  91.          '$INCLUDE: 'SEARCHH.DB'        'then include our dialog box template
  92.          Action% = 0                    'set Action% to 0
  93.          Focus% = 0                     'set the input focus to auto -- 0
  94.          CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)  'Call DiaLogic
  95.       CASE OK$
  96.          PRINT "You pushed <OK>."
  97.          ExitLoop = -1
  98.       CASE ELSE
  99.          BEEP
  100.    END SELECT
  101.  
  102. LOOP UNTIL ExitLoop
  103.  
  104. CALL HideCursor
  105. COLOR 7, 0
  106. CLS
  107. PRINT "Your search string is " + Search$ + "."
  108. IF MatchCase THEN
  109.    PRINT "Match Upper/Lower Case was checked."
  110. END IF
  111. IF WholeWord THEN
  112.    PRINT "Whole Words Only was checked."
  113. END IF
  114.  
  115.  
  116. END
  117.  
  118.